package com.isesol.ime.validator.subscription;

import com.isesol.arch.fluentvalidator.*;
import com.isesol.ime.dal.model.dto.*;
import org.apache.commons.lang3.*;
import org.springframework.stereotype.*;

@Component
public class SubscriptionCreateValidator extends ValidatorHandler<SubscriptionDTO> implements Validator<SubscriptionDTO> {


	@Override
	public boolean validate(ValidatorContext context, SubscriptionDTO subscriptionDTO) {

		boolean result = true;

		if (StringUtils.isEmpty(subscriptionDTO.getMachineId())) {

			context.addErrorMsg("params error,machineId is null");
			result = false;

		}
		if (StringUtils.isEmpty(subscriptionDTO.getUsingStatus())) {

			context.addErrorMsg("params error,usingStatus is null");
			result = false;

		}
		if (StringUtils.isEmpty(subscriptionDTO.getMsgIds())) {

			context.addErrorMsg("params error,msgIds is null");
			result = false;

		}
		if (StringUtils.isEmpty(subscriptionDTO.getMachineType())) {

			context.addErrorMsg("params error,machineType is null");
			result = false;

		}

		return result;
	}
}